import { IPSDataEntity } from '../../ipsdata-entity';
import { IPSDEFVRQueryCountCondition } from './ipsdefvrquery-count-condition';
import { PSDEFVRSingleConditionImpl } from './psdefvrsingle-condition-impl';
import { IPSDEDataQuery } from '../../ds/ipsdedata-query';

export class PSDEFVRQueryCountConditionImpl extends PSDEFVRSingleConditionImpl implements IPSDEFVRQueryCountCondition {
  get maxValue(): number {
    return this.M.maxValue;
  }

  get minValue(): number {
    return this.M.minValue;
  }

  protected psdedataquery: IPSDEDataQuery | null = null;

  getPSDEDataQuery(): IPSDEDataQuery | null {
    if (this.psdedataquery != null) return this.psdedataquery;
    const value = this.M.getPSDEDataQuery;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdedataquery = ipsdataentity.findPSDEDataQuery(value);
    }
    return this.psdedataquery;
  }

  get psDEDataQuery(): IPSDEDataQuery | null {
    return this.getPSDEDataQuery();
  }

  getPSDEDataQueryMust(): IPSDEDataQuery {
    const value = this.getPSDEDataQuery();
    if (value == null) {
      throw new Error('未指定实体数据查询对象');
    }
    return value;
  }

  get alwaysCheck(): boolean {
    return this.M.alwaysCheck;
  }

  get includeMaxValue(): boolean {
    return this.M.includeMaxValue;
  }

  get includeMinValue(): boolean {
    return this.M.includeMinValue;
  }

  get cls(): string {
    return 'PSDEFVRQueryCountConditionImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.defield.valuerule.IPSDEFVRQueryCountCondition') return true;
    return super.instanceof(cls);
  }
}
